package zsd.reiview.utility;

import java.util.ArrayList;
import java.util.List;



/**
 * @Title: NumUtility.java
 * @Package zsd.reiview.utility
 * @Description: TODO(添加描述)
 * @author 朱圣代
 * @date 2011-9-25 下午08:23:34
 * @version V1.0
 */
public class NumUtility {

	/**
	 * @Title: main
	 * @Description:
	 * @param @param args
	 * @return void
	 * @throws
	 * @date 2011-9-25 下午08:23:34
	 */

	public static int[] findListNear(int[] a1, int[] a2) {
		int[] a = new int[a1.length];
		if (a1.length == 0 || a2.length == 0)
			return a;
		for (int i = 0; i < a1.length; i++) {
			a[i] = findNearist(a2, a1[i]);
		}
		return a;
	}

	public static int[] intArray2List(List list){
		if( list == null || list.isEmpty())
			return null;
		int[] a = new int[list.size()];
		for(int i=0; i<list.size(); i++){
			Integer m =  (Integer) list.get(i);
			a[i] = m.intValue();
		}
		return a;
	}
	public static int findNearist(int[] a, int m) {
		if (a == null || a.length == 0)
			return -1;
		int mix = a[0];
		if (a.length == 1)
			return a[0];
		for (int i = 1; i < a.length; i++) {
			if ( (Math.abs( a[i] - m) ) < mix)
				mix =Math.abs( a[i] - m);
		}
		return mix;
	}

	public static void main(String[] args) {

	}

}
